<template>
	<view class="content">
		<uni-loding :loading='loading'></uni-loding>
		<view class="main-box">
			<view class="left-box">
				<block v-for="(e,i) in leftNav" :key="i">
					<view class="left-list" @click="hasLeftNav(i,e.id)">
						<view class="left-title-name" :class="{'left-nav-active':leftNavNum === i}">{{e.title}}</view>
						<view class="left-title-line" v-if="leftNavNum === i"></view>
						<view class="left-list-icon" v-if="leftNavNum === i">
							<image src="@/static/images/carNavIcon.png" mode="widthFix" class="left-nav-icon"></image>
						</view>
					</view>
				</block>
			</view>
			<view class="right-box">
				<!-- <scroll-view class="right-list-box" @scroll="scroll" scroll-y :scroll-top="scrollTop" scroll-with-animation> -->
				<scroll-view class="right-list-box" scroll-y scroll-with-animation>
					<block v-for="(d,l) in listData" :key="l">
						<view class="list-box" :id="'list-box-'+l" @click="jump(d.sn,d.title)" v-if="listData.length > 0">
							<view class="car-name">{{d.title}}</view>
							<view class="car-detail-box">
								<view class="car-price-box">
									<view class="car-price">￥{{d.price}}</view>
									<view class="car-price-tip">万起</view>
								</view>
								<view class="car-img-box">
									<image :src="d.img" mode="widthFix" class="car-img"></image>
								</view>
							</view>
						</view>
						<view class="noMore" v-else>暂无车型</view>
					</block>
				</scroll-view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				loading: false,
				leftNavNum: 0,
				leftNav: [],
				listData: []
			}
		},
		onLoad() {
			this.init();
		},
		methods: {
			init() {
				this.$func.request('/car/series').then(res => {
					this.leftNav = res.data.datas;
					this.hasCarList(res.data.datas[0].id)
				}).catch(error => {
					this.loading = false
				})
			},
			hasCarList(id) {
				this.$func.request('/car/series/'+id).then(res => {
					this.listData = res.data.data;
				}).catch(error => {
					this.loading = false
				})
			},
			
			hasLeftNav(i,id) {
				this.hasCarList(id)
				this.leftNavNum = i;
			},
			jump(sn,name){
				uni.navigateTo({
					url:'/promotionpages/car/detail?sn='+sn+'&name='+name
				})
			}
		}
	}
</script>

<style scoped>
	.main-box {
		height: 100vh;
		width: 100%;
		display: flex;
		justify-content: space-between;
		overflow: hidden;
		background: linear-gradient(180deg, #CBE2FA, #fff, #fff);
		padding-top: 20rpx;
		box-sizing: border-box;
	}

	.left-box {
		height: 100%;
		overflow: auto;
		width: 176rpx;
		background: #E7F5FF;
	}

	.left-list {
		height: 120rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: relative;
		font-size: 24rpx;
		color: #999;
	}

	.left-title-line {
		width: 24rpx;
		height: 4rpx;
		background: #2361DE;
		margin-top: 8rpx;
	}

	.left-list-icon {
		position: absolute;
		right: 0;
		top: 0;
		z-index: 0;
	}

	.left-nav-icon {
		width: 128rpx;
		height: 120rpx;
	}

	.left-nav-active {
		color: #2361DE;
		font-size: 24rpx;
		font-weight: 600;
	}

	.right-box {
		flex: 1;
		padding: 0 30rpx 0 20rpx;
	}

	.right-list-box {
		height: 100%;
	}

	.list-box {
		background: #fff;
		margin-bottom: 30rpx;
		border-radius: 20rpx;
		padding: 30rpx;
		box-sizing: border-box;
		position: relative;
		background: #fff url('@/static/images/carBottomIcon.png') no-repeat;
		background-size: 100% 100%;
	}

	.car-name {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 8rpx;
	}

	.car-detail-box {
		display: flex;
		justify-content: space-between;
	}

	.car-price-box {
		display: flex;
		align-items: baseline;
	}

	.car-price {
		color: #2361DE;
		font-size: 28rpx;
	}

	.car-price-tip {
		font-size: 20rpx;
		color: #999;
		margin-left: 4rpx
	}

	.car-img-box {
		width: 320rpx;
	}

	.car-img {
		width: 100%;
	}
</style>